function parseText(text) {
    const tagRegex = /<(\w+)([^>]*)>(.*?)<\/\1>|<(\w+)([^>]*)>/g;
    const attrRegex = /(\w+)=["']?([^"'\s>]+)["']?/g;
    let match;
    let result = {};

    if ((match = tagRegex.exec(text)) !== null) {
        let tagName = match[1] || match[4];
        let attrString = match[2] || match[5] || "";
        let innerText = match[3] || null;

        let attrMatch;
        let attribute;
        if ((attrMatch = attrRegex.exec(attrString)) !== null) {
            attribute = attrMatch[2];
        }

        const restText = text.replace(tagRegex, '');

        result = {
            type: tagName,
            attr: attribute,
            startIndex: match.index,
            innerText: innerText,
            restText: restText,
        };
    }
    else {
        result.type = 'text';
        result.restText=text;
    }
    return result;
}

// 示例使用
let text = 'hello world';
let text2 = '当前气温低至<font color="#ffa000">[106]</font>℃，请注意保暖';
let text3 = '℃，<img src=bq_01.png>请注意保暖';
let parsedText = parseText(text);
console.log(parsedText);
let parsedText2 = parseText(text2);
console.log(parsedText2);
let paredText3 = parseText(text3);
console.log(paredText3);



